package com.questionnaire.modular.system.controller;

import com.questionnaire.common.base.R;
import com.questionnaire.common.base.SimpleToken;
import com.questionnaire.common.redis.RedisUtil;
import com.questionnaire.utils.ShiroKit;
import com.questionnaire.common.base.ShiroUser;
import com.questionnaire.core.shiro.custom.CustomUsernamePwdToken;
import com.questionnaire.modular.system.model.User;
import com.questionnaire.modular.system.service.UserService;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.Serializable;

/**
 * @description:
 * @author: YSL
 * @time: 2023/11/8 14:54
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
        public R login(@RequestBody User user, HttpSession session){
            return userService.login(user);
        }
    /**
     * 退出登录
     */
    @GetMapping(value = "/logout")
    public Object ajaxLogout(HttpServletRequest request) {
        ShiroKit.getSubject().logout();
        return null;
    }

}
